package com.example.springcachedemo.service;

import com.example.springcachedemo.dao.mybatis.IUserMapper;
import com.example.springcachedemo.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @author lzh
 * @date 2020/2/27 - 11:15
 */
@Service
//@CacheConfig(cacheNames = "c1")
public class UserService {



    @Autowired
    IUserMapper userMapper;

    @Cacheable(key = "#id")
    public User getById(Long id){
//        return userRepository.findById(id).orElse(null);
        return userMapper.findById(id);
    }


}
